package test

import grails.test.*

class UserServiceTests extends GrailsUnitTestCase {

	UserService userService
	
	void setUp() {
		super.setUp()
		
		userService = new UserService()
	}
		
    void testDeleteAllBlaBlaBla() {
		mockDomain(User)
		
		// given
		new User(login: "login1", password: "pass1", email: "", birthDate: new Date(), active: true).save()
		new User(login: "login1", password: "pass1", email: "", birthDate: new Date()).save()
		new User(login: "zupa", password: "pass1", email: "", birthDate: new Date()).save()
		new User(login: "login1", password: "pass1", email: "", birthDate: new Date()).save()
		new User(login: "zupa", password: "pass1", email: "", birthDate: new Date(), active: true).save()
		
		// when
		int before = User.count()
		userService.deleteAllInactiveUsersAndActiveWithLoginZupa()
		
		// then
		assert User.count() == (before - 4)
    }
}
